<?php
require_once('lzu_op_fns.php');
if(session_status() == PHP_SESSION_NONE) {
    session_start();
}
if(!check_valid_user()){
    header("Location: login.php");
}
do_html_header('Change your personal information');
if ($_FILES["user_logo"]["error"] > 0) {
    echo "文件上传错误，错误码为：" . $_FILES["file"]["error"] . "<br>";
} else {
    try {
        $type = strchr($_FILES['user_logo']['name'], '.');
        $sno = $_SESSION['valid_user'];
        $user_logo_name = "data/user_logo/".$sno . $type;
        move_uploaded_file($_FILES['user_logo']['tmp_name'], $user_logo_name);
        $user_sex = $_POST['user_sex'];
        $user_age = $_POST['user_age'];
        $tel = $_POST['tel'];
        $user_qq = $_POST['user_qq'];
        $user_email = $_POST['user_email'];
        change_personal_information($user_logo_name, $user_sex, $user_age, $tel, $user_qq, $user_email);
        echo "修改成功";
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
echo "<a href='check.php'>点击跳转至首页</a>";
do_html_footer();
?>